<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}"/>
		<link rel="stylesheet" type="text/css" th:href="@{/css/admin.css}"/>
		<link th:href="@{/lib/font-awesome/css/font-awesome.css}" rel="stylesheet" />
	</head>
	<body>
	<form class="layui-form column-content-detail" id="actAdd">
		<div class="layui-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">添加定时任务</li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<div class="layui-form-item">
						<label class="layui-form-label">任务名称：</label>
						<div class="layui-input-block">
							<input type="text" id="jobName" name="jobName"  required lay-verify="required" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">任务分组：</label>
						<div class="layui-input-block">
							<input type="text" id="jobGroup" name="jobGroup"  required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">任务描述：</label>
						<div class="layui-input-block">
							<input type="text" id="description" name="description"  required lay-verify="required" placeholder="请输入任务描述" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">执行类：</label>
						<div class="layui-input-block">
							<input type="text" id="jobClassName" name="jobClassName"  required lay-verify="required" placeholder="请输入类的根路径" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">执行时间：</label>
						<div class="layui-input-block">
							<input type="text" id="cronExpression" name="cronExpression"  required lay-verify="required" placeholder="请查询cron表达式" autocomplete="off" class="layui-input">
						</div>
					</div>

				</div>
			</div>
		</div>
		<div class="layui-form-item" style="padding-left: 10px;">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" type="submit">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script th:src="@{/js/jquery-3.2.1.min.js}" type="text/javascript" charset="utf-8"></script>
	<script th:src="@{/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
	<script th:src="@{/js/common.js}" type="text/javascript" charset="utf-8"></script>
	<script>

            layui.use(['form', 'table', 'laydate', 'layer', 'laypage', 'dialog',  'tool', 'element', 'upload', 'layedit'], function() {
				var form = layui.form,
					layer = layui.layer,
                    table = layui.table,
					laypage = layui.laypage,
					laydate = layui.laydate,
					layedit = layui.layedit,
					tool = layui.tool,
					element = layui.element,
					dialog = layui.dialog;

				//获取当前iframe的name值
				var iframeObj = $(window.frameElement).attr('name');





		});

        $("#actAdd").bind("submit",function(){
            let data = {
                jobName:$('#jobName').val(),
                jobGroup:$('#jobGroup').val(),
                description:$('#description').val(),
                jobClassName: $("#jobClassName").val(),
                cronExpression: $("#cronExpression").val()
            };
            $.ajax({
                url: '/addTask',
                data: data,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.data == true) {
                        layer.msg('添加成功');
                    } else {
                        layer.msg('添加失败，请刷新页面');
                    }
                    let index = parent.layer.getFrameIndex(window.name);
                    setTimeout(function () {
                        //先得到当前iframe层的索引
                        parent.layer.close(index);
                        parent.layui.table.reload('test', {page: {curr: 1}});
                    }, 3000)

                }
            });
            return false;
        });


	</script>
	</body>
</html>